home *** CD-ROM | disk | FTP | other *** search
/ Small Time Crooks Press Kit / Small Time Crooks Press Kit.iso / pc / Small Time Crooks.dxr / Scripts_5.ls < prev    next >
Encoding:
Text File  |  2000-04-30  |  2.3 KB  |  88 lines

  1. on UnionLists listOfListsOrMultipleLists
  2.   if paramCount() > 1 then
  3.     set listOfLists to []
  4.     repeat with n = 1 to paramCount()
  5.       append(listOfLists, param(n))
  6.     end repeat
  7.   else
  8.     set listOfLists to param(1)
  9.   end if
  10.   if count(listOfLists) = 1 then
  11.     return duplicate(getAt(listOfLists, 1))
  12.   end if
  13.   set newList to duplicate(getAt(listOfLists, 1))
  14.   repeat with n = 2 to count(listOfLists)
  15.     set listToAdd to getAt(listOfLists, n)
  16.     repeat with listItem in listToAdd
  17.       if not getPos(newList, listItem) then
  18.         append(newList, listItem)
  19.       end if
  20.     end repeat
  21.   end repeat
  22.   return newList
  23. end
  24.  
  25. on IntersectLists listOfListsOrMultipleLists
  26.   if paramCount() > 1 then
  27.     set listOfLists to []
  28.     repeat with n = 1 to paramCount()
  29.       append(listOfLists, param(n))
  30.     end repeat
  31.   else
  32.     set listOfLists to param(1)
  33.   end if
  34.   if count(listOfLists) = 1 then
  35.     return duplicate(getAt(listOfLists, 1))
  36.   end if
  37.   set newList to duplicate(getAt(listOfLists, 1))
  38.   set listToCompare to getAt(listOfLists, 2)
  39.   set listLength to count(newList)
  40.   if not listLength then
  41.     return []
  42.   end if
  43.   repeat with itemPosition = listLength down to 1
  44.     if not getPos(listToCompare, getAt(newList, itemPosition)) then
  45.       deleteAt(newList, itemPosition)
  46.     end if
  47.   end repeat
  48.   if not count(newList) then
  49.     return []
  50.   end if
  51.   if count(listOfLists) > 2 then
  52.     set newListOfLists to duplicate(listOfLists)
  53.     setAt(newListOfLists, 1, newList)
  54.     deleteAt(newListOfLists, 2)
  55.     return IntersectLists(newListOfLists)
  56.   else
  57.     return newList
  58.   end if
  59. end
  60.  
  61. on SubtractLists listsOrListOfLists
  62.   if paramCount() > 1 then
  63.     set listOfLists to []
  64.     repeat with n = 1 to paramCount()
  65.       append(listOfLists, param(n))
  66.     end repeat
  67.   else
  68.     set listOfLists to param(1)
  69.   end if
  70.   if count(listOfLists) = 1 then
  71.     return duplicate(getAt(listOfLists, 1))
  72.   end if
  73.   set newList to duplicate(getAt(listOfLists, 1))
  74.   repeat with n = 2 to count(listOfLists)
  75.     if count(newList) = 0 then
  76.       return newList
  77.     end if
  78.     set listToSubtract to getAt(listOfLists, n)
  79.     repeat with listItem in listToSubtract
  80.       set position to getPos(newList, listItem)
  81.       if position then
  82.         deleteAt(newList, position)
  83.       end if
  84.     end repeat
  85.   end repeat
  86.   return newList
  87. end
  88.